import { createApp } from 'vue'
import App from './App.vue'

import router from './router'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from "pinia-plugin-persistedstate"

import ElementPlus from 'element-plus' // 导入 element-plus
import 'element-plus/dist/index.css'  // 导入 element-plus 样式
import zhCn from 'element-plus/es/locale/lang/zh-cn'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// ✨ 引入 Motion 插件
import { MotionPlugin } from '@vueuse/motion'

// 创建 pinia 实例并启用持久化
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

const app = createApp(App)

// 全局挂载并注册 element-plus 的所有 icon
app.config.globalProperties.$icons = []
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.config.globalProperties.$icons.push(key)
    app.component(key, component)
}

// 安装插件并挂载
app
    .use(router)
    .use(pinia)
    .use(ElementPlus, { locale: zhCn })
    .use(MotionPlugin) // 🚀 使用 Motion 插件
    .mount('#app')
